#pragma once

#include "UMLNameLabel.h"

#include "../uml/NamedElement.h"

namespace uml {

UMLNameLabel::UMLNameLabel(const QString& umlType)
    : UMLLabel(umlType) {}

void UMLNameLabel::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLLabel::fromJson(json, errorList);
    modeElement_ = JsonSerializable::create<NamedElement>(json.value("modeElement"), errorList);

}

void UMLNameLabel::toJson(QJsonObject& json) {
    UMLLabel::toJson(json);
    if (modeElement_) {
        QJsonObject modeElement_json;
        modeElement_->toJson(modeElement_json);
        json.insert("modeElement", modeElement_json);
    }
}

/// <summary>
/// modeElement getter
/// Restricts UMLNameLabels to be notation for NamedElements.
/// </summary>
shared_ptr<NamedElement> UMLNameLabel::modeElement() const {
    return modeElement_;
}

/// <summary>
/// modeElement setter
/// Restricts UMLNameLabels to be notation for NamedElements.
/// </summary>
void UMLNameLabel::setModeElement(shared_ptr<NamedElement> value) {
    modeElement_ = value;
}

} // namespace uml
